//
//  EaseCusomMessageGoodsCell.m
//  FlyingEagle
//
//  Created by Lj on 2017/6/5.
//  Copyright © 2017年 lj. All rights reserved.
//

#import "EaseCusomMessageGoodsCell.h"
#import "EaseBubbleView+Goods.h"

@implementation EaseCusomMessageGoodsCell

+ (void)initialize
{
    // UIAppearance Proxy Defaults
}

#pragma mark - IModelCell

- (BOOL)isCustomBubbleView:(id<IMessageModel>)model
{
    return YES;
}

- (void)setCustomModel:(id<IMessageModel>)model
{
    //    if (model.avatarURLPath) {
    //        [self.avatarView sd_setImageWithURL:[NSURL URLWithString:model.avatarURLPath] placeholderImage:model.avatarImage];
    //    } else {
    //        self.avatarView.image = model.avatarImage;
    //    }
    
    
    _bubbleView.leftArrow.hidden = model.isSender?YES:NO;
    _bubbleView.rightArrow.hidden = model.isSender?NO:YES;
    
    //处理数据显示
//    [ChatWorkExtensionManager theEaseBubbleView:_bubbleView model:model];
//    _bubbleView.goodsView.dataDic = model.message.ext[Goods_Info];
}

- (void)setCustomBubbleView:(id<IMessageModel>)model
{
    [_bubbleView setupWorkBubbleView];
}
- (void)updateCustomBubbleViewMargin:(UIEdgeInsets)bubbleMargin model:(id<IMessageModel>)model
{
    [_bubbleView updateWorkMargin:bubbleMargin];
}

+ (NSString *)cellIdentifierWithModel:(id<IMessageModel>)model
{
    return model.isSender?@"EaseMessageCellSendWork":@"EaseMessageCellRecvWork";
}

+ (CGFloat)cellHeightWithModel:(id<IMessageModel>)model {
    CGFloat defaultHeight = 80;
//
    EaseBaseMessageCell *cell = [self appearance];
    CGFloat minHeight = cell.avatarSize + EaseMessageCellPadding * 2;
    CGFloat height = cell.messageNameHeight;
    if ([UIDevice currentDevice].systemVersion.floatValue == 7.0) {
        height = 15;
    }
    height += EaseMessageCellPadding*2 + defaultHeight;
    height = height > minHeight ? height : minHeight;
    return height;
}

@end
